package com.example.hello;

import com.example.hello.client.TextBox.BootstrapTextBoxState;
import com.vaadin.ui.AbstractComponent;

public class BootstrapTextBox extends AbstractComponent {

    public enum TextAlignment {
        CENTER, JUSTIFY, LEFT, RIGHT
    }

    public BootstrapTextBox() {
        this(10);
    }

    public BootstrapTextBox(int maxLength) {
        setMaxLength(maxLength);
        setVisibleLength(maxLength);

        setAlignment(TextAlignment.LEFT);
        setBlockLevel(false);
        setSize(2);
        setHeight("100%");

        setImmediate(true);
    }

    @Override
    protected BootstrapTextBoxState getState() {
        return (BootstrapTextBoxState) super.getState();
    }

    public TextAlignment getAlignment() {
        return TextAlignment.valueOf(getState().getAlignment());
    }

    public void setAlignment(TextAlignment alignment) {
        getState().setAlignment(alignment.toString());
    }

    public boolean getBlockLevel() {
        return getState().isBlockLevel();
    }

    public void setBlockLevel(boolean blockLevel) {
        getState().setBlockLevel(blockLevel);
    }

    public int getMaxLength() {
        return getState().getMaxLength();
    }

    public void setMaxLength(int maxLength) {
        getState().setMaxLength(maxLength);
    }

    public String getPlaceholder() {
        return getState().getPlaceholder();
    }

    public void setPlaceholder(String placeholder) {
        getState().setPlaceholder(placeholder);
    }

    public int getSize() {
        return getState().getSize();
    }

    public void setSize(int size) {
        getState().setSize(size);
    }

    public String getText() {
        return getState().getText();
    }

    public void setText(String text) {
        getState().setText(text);
    }

    public int getVisibleLength() {
        return getState().getVisibleLength();
    }

    public void setVisibleLength(int visibleLength) {
        getState().setVisibleLength(visibleLength);
    }

}